# PowerShell script to fix @Slf4j annotations
$files = Get-ChildItem -Path 'd:\projects\zhixin\minimalist-saas' -Recurse -Name '*.java' | ForEach-Object { 'd:\projects\zhixin\minimalist-saas\' + $_ } | Where-Object { (Get-Content $_ -Raw) -match '@Slf4j' }

foreach ($file in $files) {
    Write-Host "Processing: $file"
    $content = Get-Content $file -Raw
    
    # Replace lombok import
    $content = $content -replace 'import lombok\.extern\.slf4j\.Slf4j;', 'import org.slf4j.Logger;`nimport org.slf4j.LoggerFactory;'
    
    # Remove @Slf4j annotation
    $content = $content -replace '@Slf4j\s*\n', ''
    
    # Add logger field after class declaration
    $className = [System.IO.Path]::GetFileNameWithoutExtension($file)
    $loggerField = "`n    private static final Logger log = LoggerFactory.getLogger($className.class);`n"
    
    # Find class declaration and add logger
    $content = $content -replace '(public class [^{]+\{)', "`$1$loggerField"
    
    Set-Content $file $content -Encoding UTF8
}

Write-Host "Completed processing $($files.Count) files"